################################################################################
#                                                                              #
#        Replication script for analysis contained in:                         #
#        Evaluating Death Sentencing Procedures:                               #
#        Fairness, Disparities, and Constitutional Limits                      #
#        By Barry C. Edwards, J.D., Ph.D.                                      #
#                                                                              #
#        Forthcoming in Boston U. Public Interest L. J.                        #
#        Spring 2026                                                           #
#                                                                              #
################################################################################
# There are 8 Figures and 9 Tables in the article.                             #
# Figures 1-3 are flow charts describing state procedures (not from R script). #
# Figure 4 is barplot of punitive verdicts observed by initial votes.          #
# Figures 5-7 illustrate deliberation as Markov chain process.                 #
# Figure 8 is lineplot comparing Fla. and Ala. to standard procedures.         #
# Tables 1-9 all report verdict probabilities from varying initial votes.      #
################################################################################

##################          Set-up machine          ############################
  rm(list=ls())  # starting with clean environment
  # This script requires the sate, RCPA3, and expm packages.
  # The next lines install them if you don't have them.
  if(require("sate", quietly = TRUE)==FALSE) install.packages("sate")
  if(require("RCPA3", quietly = TRUE)==FALSE) install.packages("RCPA3")
  if(require("expm", quietly = TRUE)==FALSE) install.packages("expm")
  # make sure sure you're using sate version 3.1.0 or higher
  if(packageVersion("sate") < "3.0.0") install.packages("sate")
  # load the installed sate, RCPA3, and expm packages.
  library(sate)  
  library(RCPA3)
  library(expm)
  # Load observed deliberations dataset.
  # It is saved as observed.deliberations in sate package.
  all_juries_data <- observed.deliberations
  # set working directory, change path to project folder on your machine
  setwd("C:/Users/Barry Edwards/Dropbox/jury research/Sentencing Procedures Article") # office HP desktop
  # toggle TRUE/FALSE to output hi res version of graphics to project folder
  outputGraphics <- FALSE
  noteRegardingFigures <- "Note: Figures look different in viewer compared to saved PNG files."


################# Script for Markov Chains, Figures 5-7  #######################
  
# obtain transition probabilities
transition.matrix <- sate::transition.matrix(jury_n=12)
prob_same_g <- diag(transition.matrix)
prob_lose_g <- diag(transition.matrix[, -1, drop = FALSE])
prob_add_g  <- diag(transition.matrix[-1, , drop = FALSE])

# drawing functions for convenience
  draw_chain_nodes <- function(n) {
    plot(x="", y="", ylim=c(-1,.5), xlim=c(0-.5,n+.5), asp=1, axes=F, xlab="", ylab="")
    points(x=0:n, y=rep(0, n+1), pch=21, bg="gray", cex=3.5, col="black")
    text(x=0:n, y=rep(0, n+1), labels = 0:n)
  }
  draw_up_arrow <- function(from) {
    arrow_tip_length <- .04
    h_spacer <- .325
    to <- from + 1
    arrows(x0 = from+h_spacer, x1 = to-h_spacer, y0 = .10, y1 = .10, length = arrow_tip_length)
  }
  draw_down_arrow <- function(from) {
    arrow_tip_length <- .04
    h_spacer <- .325
    to <- from - 1
    arrows(x0 = from-h_spacer, x1 = to+h_spacer, y0 = -.10, y1 = -.10, length = arrow_tip_length)
  }
  draw_return_arrow <- function(from) {
    arrow_tip_length <- .04
    h_spacer <- .05
    segments(x0 = from-h_spacer, x1 = from-h_spacer, y0 = -.60, y1 = -.325)
    arrows(x0 = from+h_spacer, x1 = from+h_spacer, y0 = -.60, y1 = -.325, length = arrow_tip_length)
    segments(x0 = from-h_spacer, x1 = from+h_spacer, y0 = -.60, y1 = -.60)
  }
simplify_labels <- function(x) {
  labels = sub("^(-?)0\\.", "\\1.", sprintf("%.2f", round(x,2)))
  return(labels)
}

# Figure 5: Markov Chain Model of 12-Member Criminal Jury Trial Deliberation
  if(outputGraphics) {
  png(file="Markov Chain Illustration 12 jurors.png", width=6, height=2,
      units="in", type="cairo", pointsize=11, res=300, antialias="default")
  }
    par(mar=c(0, 0, 0, 0), family="serif")
    draw_chain_nodes(12)
    draw_up_arrow(from=1:11) # increase by one
    # values <- round(prob_add_g[2:12],2)
    # labels <- sub("^(-?)0\\.", "\\1.", sprintf("%.2f", values))
    text(x = (1:11)+.5, y = .10, pos=3, label=simplify_labels(prob_add_g[2:12]), cex=.8)
    draw_down_arrow(from=1:11) # decrease by one
    text(x = (0:10)+.5, y = -.10, pos=1, label=simplify_labels(prob_lose_g[1:11]), cex=.8)
    draw_return_arrow(from=0:12) # stay the same
    text(x = (0:12), y = -.55, pos=1, label=simplify_labels(prob_same_g), cex=.8)
  if(outputGraphics) dev.off() else message(noteRegardingFigures)

  
# Figure 6. Death Penalty Deliberation Under Florida’s Verdict Rule
  if(outputGraphics) {
      png(file="Markov Chain Florida death rule.png", width=6, height=2,
          units="in", type="cairo", pointsize=11, res=300, antialias="default")
  }
    par(mar=c(0, 0, 0, 0), family="serif")
    draw_chain_nodes(12)
    draw_up_arrow(from=1:7) # increase by one
    text(x = (1:7)+.5, y = .10, pos=3, label=simplify_labels(prob_add_g[2:8]), cex=.8)
    draw_down_arrow(from=1:7) # decrease by one
    text(x = (0:6)+.5, y = -.10, pos=1, label=simplify_labels(prob_lose_g[1:7]), cex=.8)
    draw_return_arrow(from=0:12) # stay the same
    text(x = (0:12), y = -.55, pos=1, label=simplify_labels(c(prob_same_g[1:8],1,1,1,1,1)), cex=.8)
  if(outputGraphics) dev.off() else message(noteRegardingFigures)
    
  
# Figure 7. Death Penalty Deliberation Under Alabama’s Verdict Rule (created in 2 parts)
  if(outputGraphics) {
      png(file="Markov Chain Alabama death rule one sided.png", width=6, height=2,
          units="in", type="cairo", pointsize=11, res=300, antialias="default")
  }
    par(mar=c(0, 0, 0, 0), family="serif")
    draw_chain_nodes(12)
    draw_up_arrow(from=1:9) # increase by one
    # arrows(x0 = (1:9)+.30, x1 = (2:10)-.30, y0 = .10, y1 = .10, length = arrow_tip_length)
    text(x = (1:9)+.5, y = .10, pos=3, label=simplify_labels(prob_add_g[2:10]), cex=.8)
    draw_down_arrow(from=1:9) # decrease by one
    # arrows(x0 = (1:9)-.30, x1 = (0:8)+.30, y0 = -.10, y1 = -.10, length = arrow_tip_length)
    text(x = (0:8)+.5, y = -.10, pos=1, label=simplify_labels(prob_lose_g[1:9]), cex=.8)
    draw_return_arrow(from=0:12) # stay the same
    text(x = (0:12), y = -.55, pos=1, label=simplify_labels(c(prob_same_g[1:10],1,1,1)), cex=.8)
  if(outputGraphics) dev.off() else message(noteRegardingFigures)
    
  if(outputGraphics) {
      png(file="Markov Chain Alabama death rule two sided.png", width=6, height=2,
          units="in", type="cairo", pointsize=11, res=300, antialias="default")
    }
    par(mar=c(0, 0, 0, 0), family="serif")
    draw_chain_nodes(12)
    draw_up_arrow(from=6:9) # increase by one
    text(x = (6:9)+.5, y = .10, pos=3, label=simplify_labels(prob_add_g[7:10]), cex=.8)
    draw_down_arrow(from=6:9) # decrease by one
    text(x = (5:8)+.5, y = -.10, pos=1, label=simplify_labels(prob_lose_g[6:9]), cex=.8)
    draw_return_arrow(from=0:12) # stay the same
    text(x = (0:12), y = -.55, pos=1, label=simplify_labels(c(1,1,1,1,1,1,prob_same_g[7:10],1,1,1)), cex=.8)
  if(outputGraphics) dev.off() else message(noteRegardingFigures)
    
    
  
############### Script for Tables 1-9 and Figures 4 & 8 ########################
  
  # helper function for display of probabilities in tables
    display_probabilities <- function(x) {
      fmt <- function(v) sub("^(-?)0\\.", "\\1.", sprintf("%.3f", round(v, 3)))
      if (is.data.frame(x) || is.matrix(x)) {
        return(apply(x, c(1, 2), fmt))
      } else {
        return(fmt(x))
      }
    }
  # helper function to neatly print tables
    print_table_neatly <- function(x) {
      print(as.data.frame(cbind(initial_vote=paste(0:12,"-",12:0,sep=""), 
                                display_probabilities(x))), quote = FALSE, right = T, row.names=FALSE)
    }
    
    
# Figure 4. Observed Relationship Between Jurors’ Initial Vote and Verdict Probabilities 
  all_juries_data$initial_punitive_votes <- round(all_juries_data$prop_jurors_g * all_juries_data$jury_size)
  all_juries_data$initial_punitive_fraction <- all_juries_data$initial_punitive_votes / all_juries_data$jury_size
  observed_punitive_probs <- RCPA3::compmeansC(dv=all_juries_data$guilty_verdict, 
                                               iv=factor(all_juries_data$initial_punitive_fraction), plot=F)
  observed_punitive_probs <- as.numeric(observed_punitive_probs[,"Mean"])
  
if(outputGraphics) {
    png(file="basic observed bar plot punitive verdicts.png", width=4, height=3, 
        units="in", type="cairo", pointsize=11, res=300, antialias="default")
}
  yaxis_labels <- c("0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0")
  par(mar=c(3, 3.25, 0, 0), family="serif", mfrow=c(1,1), omi=base::c(0.1,0.1,0.1,0.1), tck=-.02)
  fraction_labels <- c(0, expression(frac(1,12)), expression(frac(1, 6)),  
                       expression(frac(1, 4)), expression(frac(1, 3)), expression(frac(5, 12)),  
                       expression(frac(1, 2)), expression(frac(7, 12)), expression(frac(2, 3)),  
                       expression(frac(3, 4)), expression(frac(5, 6)), expression(frac(11, 12)), 
                       1)
  barplot(height = observed_punitive_probs[1:13], cex.names=.8, ann = T, 
          col = c("gray90"), 
          # legend.text=c("Observed results"),
          args.legend=list(x=7.5, y=1, cex=.9, box.col = "white", box.lty = 0),
          xlab="", ylab="", axes=F, ylim=c(0,1.05), space = .25)
  axis(side=2, at=seq(0, 1, by=.10), labels = yaxis_labels, las=2, cex.axis=.8)
  mtext(side=1, at=.75 + 0:12*1.25, text = fraction_labels, cex=c(.8,rep(.6,11),.8), line = .25, padj = .5)
  mtext(side = 1, text = "Initial Fraction of Jurors for Punitive Verdict", cex = .9, line = 2)
  mtext(side = 2, text = "Proportion of Punitive Verdicts", cex = .9, line = 2)
if(outputGraphics) dev.off() else message(noteRegardingFigures)
  


# Section III-A, hung jury analysis
# This hung jury analysis is not reported in table, but the empirical_cutoff_round
# value is important for subsequent analysis reported in Tables.
  
  # transition probabilities from standard procedures
  transition_matrix <- sate::transition.matrix(12)
  n_jurors <- 12
  
  # what is the empirical distribution of initial votes on 12-person juries?
  all_juries_data$initial_guilty_votes[all_juries_data$jury_size==12] <- round(all_juries_data$prop_jurors_g[all_juries_data$jury_size==12] * all_juries_data$jury_size[all_juries_data$jury_size==12])
  observed_k_n12 <- RCPA3::freqC(all_juries_data$initial_guilty_votes[all_juries_data$jury_size==12], plot=F)
  observed_k_proportions <- observed_k_n12$Percent[1:13]/100
  
  # how many rounds until only .062 of juries still deliberating?
  round <- 1
  not_guilty_verdicts <- guilty_verdicts <- still_deliberating <- NULL
  next_matrix <- transition_matrix %*% observed_k_proportions
  while(sum(next_matrix[-c(1,n_jurors+1),]) > .062) # .062 is observed hung jury rate
  {
    still_deliberating[round] <- sum(next_matrix[-c(1,n_jurors+1),])
    not_guilty_verdicts[round] <- next_matrix[1,1]
    guilty_verdicts[round] <- next_matrix[n_jurors+1,1]
    next_matrix <-   transition_matrix %*% next_matrix
    round <- round + 1
  }
  empirical_cutoff_round <- round
  # Sanity checks:
  # plot(still_deliberating)
  # plot(not_guilty_verdicts)
  # plot(guilty_verdicts)


# Table 1. Probabilities of Death, Life, and Impasse Outcomes Given Jury’s Initial Vote
# the standard_probabilities data.frame used for subsequent analysis
  result <- transition_matrix %^% empirical_cutoff_round
  standard_probabilities <- data.frame(prob_death=result[n_jurors+1,], 
                                       prob_life=result[1,],
                                       prob_impasse=1-result[n_jurors+1,]-result[1,])
  invisible(RCPA3:::headingbox("Probabilities of Death, Life, and Impasse Outcomes Given Jury’s Initial Vote"))
  print_table_neatly(standard_probabilities)


###### Table 2. Comparison of Judge and Jury Decisions
  kalven_zeisel_data <- matrix(
    c(  # Jury Lenient, Jury Punitive, Jury Impasse
                 479,           79,            39,    # Judge Lenient row
                 604,         2217,            157  # Judge Punitive row
    ), nrow = 2, byrow = TRUE, dimnames = list(
      Judge = c("Lenient", "Punitive"),
      Jury  = c("Lenient", "Punitive", "Impasse")))
  hannaford_agor_data <- matrix(
    c( # Jury Lenient, Jury Punitive, Jury Impasse
                37,           16,            6,    # Judge Lenient row
                51,          186,            22  # Judge Punitive row
    ), nrow = 2, byrow = TRUE, dimnames = list(
      Judge = c("Lenient", "Punitive"),
      Jury  = c("Lenient", "Punitive", "Impasse")))
  eisenberg_data <- matrix(
    c( # Jury Lenient, Jury Punitive, Jury Impasse
                42,           9,            8,    # Judge Lenient row
                65,         133,           35  # Judge Punitive row
    ), nrow = 2, byrow = TRUE, dimnames = list(
      Judge = c("Lenient", "Punitive"),
      Jury  = c("Lenient", "Punitive", "Impasse")))
  
  combined_data <- kalven_zeisel_data + hannaford_agor_data + eisenberg_data
  # combined_data
  invisible(RCPA3:::headingbox("Comparison of Judge and Jury Decisions"))
  addmargins(combined_data)               # row/column totals
  col_props <- prop.table(combined_data, 2)            # within-jury proportions
  round(col_props*100,1)

  
# Table 3. Effect of Judges Making Selection Decision on the Probability of a Death Sentence
  prob_judge_punitive_jury_lenient  <- col_props["Punitive","Lenient"]
  prob_judge_punitive_jury_punitive <- col_props["Punitive","Punitive"]
  prob_judge_punitive_jury_impasse  <- col_props["Punitive","Impasse"]
  prob_judge_lenient_jury_punitive  <- col_props["Lenient","Punitive"]
  prob_death_1judge <-  (standard_probabilities$prob_death   * prob_judge_punitive_jury_punitive) +
                        (standard_probabilities$prob_life    * prob_judge_punitive_jury_lenient) +
                        (standard_probabilities$prob_impasse * prob_judge_punitive_jury_impasse) 
  prob_death_3judges <- prob_death_1judge^3
  judge_differences <- data.frame(one_judge=prob_death_1judge - standard_probabilities$prob_death, 
                                  three_judges=prob_death_3judges - standard_probabilities$prob_death)
  invisible(RCPA3:::headingbox("Effect of Judges Making Selection Decision on the Probability of a Death Sentence"))
  print_table_neatly(judge_differences)

  
  
# Table 4. Effect of Florida’s 8-4 Majority Vote Rule on Sentencing Probabilities
  # start with standard transition matrix
  fla_8_4_matrix <- transition_matrix 
  # modify to make 8-11 votes for death absorbing states like 12 votes
  fla_8_4_matrix[, 9:12] <- fla_8_4_matrix[, 13]
  # deliberate to empirical_cutoff_round
  result <- fla_8_4_matrix %^% empirical_cutoff_round
  fla_8_4_probabilities <- data.frame(prob_death=result[n_jurors+1,], 
                                       prob_life=result[1,],
                                       prob_impasse=1-result[n_jurors+1,]-result[1,])
  invisible(RCPA3:::headingbox("Effect of Florida’s 8-4 Majority Vote Rule on Sentencing Probabilities"))
  print_table_neatly(fla_8_4_probabilities - standard_probabilities)

  

# Table 5. Effect of Alabama’s 10-2 Majority Vote Rule on Outcome Probabilities 
#          Compared to Unanimity Rule Given Jury’s Initial Vote
  # Alabama 10-2 majority rule (for death only)
  # start with standard transition matrix
  ala_10_2_matrix <- transition_matrix 
  # modify to make 10-11 votes for death absorbing states like 12 death votes
  ala_10_2_matrix[, 11:12] <- ala_10_2_matrix[, 13]
  # deliberate to empirical_cutoff_round
  result <- ala_10_2_matrix %^% empirical_cutoff_round
  ala_10_2_probabilities<- data.frame(prob_death=result[n_jurors+1,], 
                                      prob_life=result[1,],
                                      prob_impasse=1-result[n_jurors+1,]-result[1,])
  
  # Alabama 10-2 majority rule (10 for death & 7 for life)
  # start with standard transition matrix
  ala_10death_7life_matrix <- transition.matrix
  # modify to make 10-11 votes for death absorbing states like 12 death votes
  ala_10death_7life_matrix[, 11:12] <- ala_10death_7life_matrix[, 13]
  # further modify to make 1-5 votes for death absorbing states like 0 death votes
  ala_10death_7life_matrix[, 2:6] <- ala_10death_7life_matrix[, 1]
  # deliberate to empirical_cutoff_round
  result <- ala_10death_7life_matrix %^% empirical_cutoff_round
  ala_10_2_twosided <- data.frame(prob_death=result[n_jurors+1,], 
                                      prob_life=result[1,],
                                      prob_impasse=1-result[n_jurors+1,]-result[1,])
  invisible(RCPA3:::headingbox("Effect of Alabama’s 10-2 Majority Vote Rule, Two Interpretations"))
  print_table_neatly(cbind(ala_10_2_probabilities - standard_probabilities, ala_10_2_twosided  - standard_probabilities))



# Figure 8. Comparing Effects of Florida and Alabama Majority Verdict Rules
  PD_from_standard_pro <- standard_probabilities$prob_death
  PD_under_fla_maj_rule <- fla_8_4_probabilities$prob_death
  PD_Alabama_2sided_rule <- ala_10_2_twosided$prob_death
  upper_limit <- PD_from_standard_pro + .10
  lower_limit <- PD_from_standard_pro - .10
  
  if(outputGraphics) {
  png(file="standard procedure with acceptable buffer.png", width=5, height=3, 
      units="in", type="cairo", pointsize=10, res=300, antialias="default")
  }
    par(mar=c(4, 4, 1, 1), mfrow=c(1,1), family="serif", mgp=c(.5,1,0))
    axis_tick_labels <- c("0.0", "0.1", "0.2", "0.3", "0.4", "0.5", "0.6", "0.7", "0.8", "0.9", "1.0")
    
    plot(xlab = "", ylab = "", x="", y="", type="n", xlim=c(0,1), ylim=c(0,1.05), axes=F)
    abline(h=seq(0,1,.1), col="gray95")
    abline(v=seq(0,1,by=.1), col="gray95")
    
    polygon(x=c(seq(0,12,by=1)/12, rev(seq(0,12,by=1)/12)), y= c(lower_limit, rev(upper_limit)), 
            col = "gray90", border = F)
    lines(x = seq(0,12,by=1)/12, y = PD_under_fla_maj_rule, lwd=1.5, col="orange")
    points(x = seq(0,12,by=1)/12, y = PD_under_fla_maj_rule, pch=22, col="orange", bg="white")
    lines(x = seq(0,12,by=1)/12, y = PD_Alabama_2sided_rule, lwd=1.5, col="red")
    points(x = seq(0,12,by=1)/12, y = PD_Alabama_2sided_rule, pch=23, col="red", bg="white")
    lines(x = seq(0,12,by=1)/12, y = PD_from_standard_pro, lwd=1.5)
    points(x = seq(0,12,by=1)/12, y = PD_from_standard_pro, pch=21, col="black", bg="white")
    axis(side=2, at=seq(-.1,1,by=.1), labels = c("",axis_tick_labels), las=2, cex.axis=.9, line=.1)
    axis(side=1, at=seq(-1,12,by=1)/12, labels = -1:12, cex.axis=.9, line=.1)
    mtext(side = 1, text = "Jurors Initially in Favor of Death Sentence", cex = 1, line = 2.25)
    mtext(side = 2, text = "Probability of Death Sentence", cex = 1, line = 2.5)
    legend(x=0.01,y=1, legend = c(" Florida", " Alabama", " Modal procedures"), pch = c(22, 5, 1), 
           cex = .9, bty = "n", col=c("orange", "red", "black"))
    legend(x=0, y=.76, legend = c("+/- .10 buffer"), fill="gray80", border = F,
           cex = .9, bty = "n")
  if(outputGraphics) dev.off() else message(noteRegardingFigures)
    


# Table 6. Probability of Death Sentence by Initial Poll and Verdict Rule
  # Hypothetical 11-1 rule
  # start with standard transition matrix
  hypo_11_1_matrix <- transition_matrix 
  # modify to make 11 votes for death absorbing states like 12 death votes
  hypo_11_1_matrix[, 12] <- hypo_11_1_matrix[, 13]
  # deliberate to empirical_cutoff_round
  result <- hypo_11_1_matrix %^% empirical_cutoff_round
  hypo_11_1_probabilities<- data.frame(prob_death=result[n_jurors+1,], 
                                      prob_life=result[1,],
                                      prob_impasse=1-result[n_jurors+1,]-result[1,])
  # Hypothetical 9-3 rule
  # start with standard transition matrix
  hypo_9_3_matrix <- transition.matrix
  # modify to make 9-11 votes for death absorbing states like 12 death votes
  hypo_9_3_matrix[, 10:12] <- hypo_9_3_matrix[, 13]
  # deliberate to empirical_cutoff_round
  result <- hypo_9_3_matrix %^% empirical_cutoff_round
  hypo_9_3_probabilities<- data.frame(prob_death=result[n_jurors+1,], 
                                       prob_life=result[1,],
                                       prob_impasse=1-result[n_jurors+1,]-result[1,])
  # Hypothetical 7-5 rule
  # start with standard transition matrix
  hypo_7_5_matrix <- transition_matrix 
  # modify to make 7-11 votes for death absorbing states like 12 death votes
  hypo_7_5_matrix[, 8:12] <- hypo_7_5_matrix[, 13]
  # deliberate to empirical_cutoff_round
  result <- hypo_7_5_matrix %^% empirical_cutoff_round
  hypo_7_5_probabilities<- data.frame(prob_death=result[n_jurors+1,], 
                                      prob_life=result[1,],
                                      prob_impasse=1-result[n_jurors+1,]-result[1,])
  effects_by_rule <- data.frame(
    effect_11_1= hypo_11_1_probabilities$prob_death - standard_probabilities$prob_death,
    effect_10_2= ala_10_2_probabilities$prob_death - standard_probabilities$prob_death,
    effect_9_3 = hypo_9_3_probabilities$prob_death - standard_probabilities$prob_death,
    effect_8_4 = fla_8_4_probabilities$prob_death - standard_probabilities$prob_death,
    effect_7_5 = hypo_7_5_probabilities$prob_death - standard_probabilities$prob_death)
  invisible(RCPA3:::headingbox("Probability of Death Sentence by Initial Poll and Verdict Rule"))
  print_table_neatly(effects_by_rule)



# Table 7. Effect of Varying Responses to Impasse on Probability of Death Sentence
  standard_probabilities$prob_impasse
  effect_by_rule <- data.frame(judge_decides = standard_probabilities$prob_impasse * prob_death_1judge,
                               one_retrial   = standard_probabilities$prob_impasse * standard_probabilities$prob_death,
                               unlimited_retrials = standard_probabilities$prob_impasse * (standard_probabilities$prob_death / (1 - standard_probabilities$prob_impasse)))
  invisible(RCPA3:::headingbox("Effect of Varying Responses to Impasse on Probability of Death Sentence"))
  print_table_neatly(effect_by_rule)

  

# Table 8. Effect of Judicial Override of Jury Verdicts
  effect_by_rule <- data.frame(punitive_override = standard_probabilities$prob_life *  prob_judge_punitive_jury_lenient,
                               merciful_override = standard_probabilities$prob_death * prob_judge_lenient_jury_punitive * -1)
  invisible(RCPA3:::headingbox("Effect of Judicial Override of Jury Verdicts"))
  print_table_neatly(effect_by_rule)



# Table 9. Net Effect of State Sentencing Procedures on Death Sentence Probabilities
  ala_10_2_death_and_retrials <- ala_10_2_probabilities$prob_death + (ala_10_2_probabilities$prob_impasse * (ala_10_2_probabilities$prob_death / (1 - ala_10_2_probabilities$prob_impasse)))
  ala_twosided_and_retrials  <- ala_10_2_twosided$prob_death + (ala_10_2_twosided$prob_impasse * (ala_10_2_twosided$prob_death / (1 - ala_10_2_twosided$prob_impasse)))
  fla_8_4_merciful_overrides <- fla_8_4_probabilities$prob_death - (fla_8_4_probabilities$prob_death * prob_judge_lenient_jury_punitive) 
  effect_by_rule <- data.frame(ala_10death_and_retrials = ala_10_2_death_and_retrials - standard_probabilities$prob_death,
                               ala_twosided_and_retrials = ala_twosided_and_retrials - standard_probabilities$prob_death,
                               fla_8death_merciful_overrides = fla_8_4_merciful_overrides - standard_probabilities$prob_death)
  invisible(RCPA3:::headingbox("Net Effect of State Sentencing Procedures on Death Sentence Probabilities"))
  print_table_neatly(effect_by_rule)


